<template>
  <div class="emp-box">
    <!-- 面包屑 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/loginRedirect' }"
        >首页</el-breadcrumb-item
      >
      <el-breadcrumb-item>通用审批</el-breadcrumb-item>
      <el-breadcrumb-item>离职申请</el-breadcrumb-item>
    </el-breadcrumb>

    <div style="padding: 50px 150px 30px 150px">
      <el-form ref="form" :model="quitForm" label-width="80px">
        <el-form-item label="离职原因">
          <el-input v-model="quitForm.applyTitle" placeholder="请输入标题"></el-input>
        </el-form-item>
        <el-form-item label="请假时间">
          <div style="display: inline-block; width: 600px; line-heigth: 30px">
            <div style="display: inline-block">
              <el-date-picker
                type="datetime"
                v-model="quitForm.endDate"
                placeholder="离职日期"
                style="width: 100%"
                value-format="yyyy-MM-dd HH:mm:ss"
                readonly
              ></el-date-picker>
            </div>
          </div>
        </el-form-item>
        <el-form-item label="请假类型">
          <el-radio-group v-model="quitForm.typeId">
            <el-radio label="离职"></el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="补充说明">
          <el-input type="textarea" :rows="10" v-model="quitForm.applyDetail" placeholder="离职补充说明"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="applyQuit()">提 交 申 请</el-button>
          <el-button type="warning" @click="reset()">信 息 重 置</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      quitForm:{
        applyTitle:"",
        endDate: new Date(),
        typeId:-1,
        applyDetail:""
      },
    };
  },
  methods: {
    // 申请离职
    applyQuit(){
      if(this.quitForm.applyTitle === ""){
        return this.$message.warning("请输入离职标题!!!");
      }
      this.quitForm.typeId = -1;
      this.$http.post("/approval/resignApply",this.quitForm).then((res)=>{
        // console.log(res);
        if(res.data){
          this.$message.success("申请成功!!!");
          this.quitForm.applyTitle = "";
          this.quitForm.applyDetail = "";
          this.quitForm.endDate = new Date();
        }else{
          this.$message.error("申请失败!!!");
        }
      }).catch((err)=>{
        this.$message.error("申请失败!!!");
      }); 
    },
    reset(){
      this.quitForm.applyTitle = "";
      this.quitForm.applyDetail = "";
    }
  }
};
</script>

<style scoped>
.emp-box .search-box {
  width: 30%;
  margin-top: 20px;
}
</style>
